/*
 * Recursion.cpp
 *
 *  Created on: Mar 3, 2014
 *      Author: tony
 */

#include <iostream>
#include <string>

void writebackwards1(std::string a, int n) {
	if (n<0)
		return;
	std::cout << a[n-1];
	writebackwards1(a,n-1);
}

void writebackwards2(std::string a, int start) {
	if (start>=a.length())
		return;
	writebackwards2(a,start+1);
	std::cout << a[start];
}

int main(){
	std::string s = "Hello";

	std::cout << " s is: " << s << std::endl;

	std::cout << " backwards, it is: ";
	writebackwards1( s, s.length() );
	std::cout << std::endl;

	std::cout << " backwards, it is: ";
	writebackwards2( s, 0 );
	std::cout << std::endl;
}
